﻿package frEngine.pools
{
    import flash.utils.*;
    import frEngine.effectEditTool.manager.*;

    public class FrObjectPool extends Object
    {
        private static var pools:Dictionary = new Dictionary();
        public static var _effectCreateNum:int = 0;

        public function FrObjectPool()
        {
            return;
        }// end function

        public static function getPool(param1:Class) : Array
        {
            return param1 in pools ? (pools[param1]) : (var _loc_2:* = new Array(), pools[param1] = new Array(), _loc_2);
        }// end function

        public static function getObject(param1:Class, param2:Object, ... args)
        {
            var _loc_5:IPoolObject = null;
            args = getPool(param1);
            if (args.length > 0)
            {
                _loc_5 = args.pop();
            }
            else
            {
                _loc_5 = FrConstruct(param1, args);
                if (_loc_5 is Obj3dContainer)
                {
                    var _loc_7:* = _effectCreateNum + 1;
                    _effectCreateNum = _loc_7;
                    if (_effectCreateNum > 20)
                    {
                        trace("effectNum:" + _effectCreateNum);
                    }
                }
            }
            _loc_5.isDisposed = false;
            _loc_5.user = param2;
            return _loc_5;
        }// end function

        public static function disposeObject(param1:IPoolObject, param2:Class = null) : void
        {
            var _loc_4:String = null;
            if (param1.isDisposed)
            {
                return;
            }
            param1.isDisposed = true;
            param1.user = null;
            if (!param2)
            {
                _loc_4 = getQualifiedClassName(param1);
                param2 = getDefinitionByName(_loc_4) as Class;
            }
            var _loc_3:* = getPool(param2);
            _loc_3.push(param1);
            return;
        }// end function

        public static function getPoolMsg() : String
        {
            var _loc_3:* = undefined;
            var _loc_4:Array = null;
            var _loc_1:String = "";
            var _loc_2:int = 0;
            for (_loc_3 in pools)
            {
                
                _loc_4 = getPool(_loc_3);
                _loc_2 = _loc_2 + _loc_4.length;
                _loc_1 = _loc_1 + (_loc_3 + ":<font color=\'#00FF00\'>" + _loc_4.length + "</font>\n");
            }
            return "对象池总对象数量：<font color=\'#00FF00\'>" + _loc_2 + "</font>\n" + _loc_1;
        }// end function

        public static function clearPool() : void
        {
            pools = new Dictionary();
            return;
        }// end function

    }
}
